package com.qiyi.player.wonder.plugins.scenetile.model
{
   import org.puremvc.as3.patterns.proxy.Proxy;
   import com.qiyi.player.wonder.common.status.IStatus;
   import com.qiyi.player.wonder.common.status.Status;
   import com.qiyi.player.base.logging.ILogger;
   import com.qiyi.player.wonder.plugins.scenetile.SceneTileDef;
   import flash.external.ExternalInterface;
   import com.adobe.serialization.json.JSON;
   import com.qiyi.player.base.logging.Log;
   
   public class SceneTileProxy extends Proxy implements IStatus
   {
      
      public function SceneTileProxy(param1:Object = null) {
         this._log = Log.getLogger(NAME);
         super(NAME,param1);
         this._status = new Status(SceneTileDef.STATUS_BEGIN,SceneTileDef.STATUS_END);
         this._status.addStatus(SceneTileDef.STATUS_TOOL_VIEW_INIT);
      }
      
      public static const NAME:String = "com.qiyi.player.wonder.plugins.scenetile.model.SceneTileProxy";
      
      private var _status:Status;
      
      private var _lastPlayingDuration:int = 0;
      
      private var _lifePlayingDuration:int = 0;
      
      private var _lotteryShowTime:int = -1;
      
      private var _isAlreadyShowFocus:Boolean = false;
      
      private var _focusInfo:Object = null;
      
      private var _log:ILogger;
      
      public function get focusInfo() : Object {
         return this._focusInfo;
      }
      
      public function set focusInfo(param1:Object) : void {
         this._focusInfo = param1;
      }
      
      public function get isAlreadyShowFocus() : Boolean {
         return this._isAlreadyShowFocus;
      }
      
      public function set isAlreadyShowFocus(param1:Boolean) : void {
         this._isAlreadyShowFocus = param1;
      }
      
      public function get lastPlayingDuration() : int {
         return this._lastPlayingDuration;
      }
      
      public function set lastPlayingDuration(param1:int) : void {
         this._lastPlayingDuration = param1;
      }
      
      public function get lifePlayingDuration() : int {
         return this._lifePlayingDuration;
      }
      
      public function set lifePlayingDuration(param1:int) : void {
         this._lifePlayingDuration = param1;
      }
      
      public function get lotteryShowTime() : int {
         return this._lotteryShowTime;
      }
      
      public function set lotteryShowTime(param1:int) : void {
         this._lotteryShowTime = param1;
      }
      
      public function get status() : Status {
         return this._status;
      }
      
      public function addStatus(param1:int, param2:Boolean = true) : void {
         if(param1 >= SceneTileDef.STATUS_BEGIN && param1 < SceneTileDef.STATUS_END && !this._status.hasStatus(param1))
         {
            if(param1 == SceneTileDef.STATUS_TOOL_OPEN && !this._status.hasStatus(SceneTileDef.STATUS_TOOL_VIEW_INIT))
            {
               this._status.addStatus(SceneTileDef.STATUS_TOOL_VIEW_INIT);
               sendNotification(SceneTileDef.NOTIFIC_ADD_STATUS,SceneTileDef.STATUS_TOOL_VIEW_INIT);
            }
            else if(param1 == SceneTileDef.STATUS_DETAILS_OPEN && !this._status.hasStatus(SceneTileDef.STATUS_DETAILS_VIEW_INIT))
            {
               this._status.addStatus(SceneTileDef.STATUS_DETAILS_VIEW_INIT);
               sendNotification(SceneTileDef.NOTIFIC_ADD_STATUS,SceneTileDef.STATUS_DETAILS_VIEW_INIT);
            }
            else if(param1 == SceneTileDef.STATUS_GREEN_TAIL_OPEN && !this._status.hasStatus(SceneTileDef.STATUS_GREEN_TAIL_VIEW_INIT))
            {
               this._status.addStatus(SceneTileDef.STATUS_GREEN_TAIL_VIEW_INIT);
               sendNotification(SceneTileDef.NOTIFIC_ADD_STATUS,SceneTileDef.STATUS_GREEN_TAIL_VIEW_INIT);
            }
            else if(param1 == SceneTileDef.STATUS_FOCUS_OPEN && !this._status.hasStatus(SceneTileDef.STATUS_FOCUS_VIEW_INIT))
            {
               this._status.addStatus(SceneTileDef.STATUS_FOCUS_VIEW_INIT);
               sendNotification(SceneTileDef.NOTIFIC_ADD_STATUS,SceneTileDef.STATUS_FOCUS_VIEW_INIT);
            }
            
            
            
            this._status.addStatus(param1);
            if(param2)
            {
               sendNotification(SceneTileDef.NOTIFIC_ADD_STATUS,param1);
            }
         }
      }
      
      public function removeStatus(param1:int, param2:Boolean = true) : void {
         if(param1 >= SceneTileDef.STATUS_BEGIN && param1 < SceneTileDef.STATUS_END && (this._status.hasStatus(param1)))
         {
            this._status.removeStatus(param1);
            if(param2)
            {
               sendNotification(SceneTileDef.NOTIFIC_REMOVE_STATUS,param1);
            }
         }
      }
      
      public function hasStatus(param1:int) : Boolean {
         return this._status.hasStatus(param1);
      }
      
      public function requestLogin() : void {
         var dataProvider:Object = null;
         this._log.debug("call js callJsLogin ");
         try
         {
            dataProvider = new Object();
            dataProvider.type = "requestLogin";
            ExternalInterface.call("lib.swf.notice",com.adobe.serialization.json.JSON.encode(dataProvider));
         }
         catch(error:Error)
         {
            _log.debug("call js callJsLogin error");
         }
      }
   }
}
